# Maintainer:
# Contributor: Felix Yan <felixonmars@archlinux.org>

_name=manuel
pkgname=python-manuel
pkgver=1.12.4
pkgrel=4
pkgdesc="Manuel lets you build tested documentation"
arch=(any)
license=(Apache)
url="https://github.com/benji-york/manuel"
depends=(
  python
  python-six # six is still required during check(): https://github.com/benji-york/manuel/issues/33
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-zope-testing)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('cd65307f2ca94e66d88bc0c7c75702d49f505b358ebb812fd20906036ba10f2d1d11d2d69404b88c5f10b584dea05a988b5dc8ba07210b9d20ebd8a11b701633')
b2sums=('e15f9261854fbad8ee1e1dc8645ec286a212c460a78fff1576b6886d8bf462ffe9a5484338fd9efc2bf053a7689e16b08de55f763ae319e66a363c5c28cf2a60')

prepare() {
  # setuptools not needed: https://github.com/benji-york/manuel/issues/36
  sed -e "/'setuptools',/d" -i $_name-$pkgver/setup.py
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

# tests currently broken: https://github.com/benji-york/manuel/issues/34
# check() {
#   local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

#   cd $_name-$pkgver
#   python -m installer --destdir=test_dir dist/*.whl
#   export PYTHONPATH="test_dir/$site_packages:$PYTHONPATH"

#   python -m unittest discover -vs src/$_name/
#   python src/$_name/tests.py
# }

package() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  rm -frv "$pkgdir/$site_packages/$_name/"tests.py
}
